import java.util.Arrays;

public class L283 {

    public static void main(String[] args) {
        int[] arr = {4, 2, 4, 0, 0, 3, 0, 5, 1, 0};
//        int[] arr = {0, 1, 0, 3, 12};
//        int[] arr = {1, 0, 1, 0};
        new Solution().moveZeroes(arr);
    }

    static class Solution {
        public void moveZeroes(int[] nums) {
            if (nums.length < 2) {
                return;
            }
            int i = 0;
            int j = 1;

            while (j < nums.length) {
                if (nums[j] == 0) {
                    j++;
                    if (nums[i] != 0) {
                        i++;
                    }
                    continue;
                }

                if (nums[i] == 0) {
                    int tmp = nums[i];
                    nums[i] = nums[j];
                    nums[j] = tmp;
                }
                i++;
                j++;
            }
            System.out.println(Arrays.toString(nums));

        }
    }
}
